﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed), ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
    public class PrintReportService : IPrintReportService
    {
        public DataSet GetEncasingDetailNote(string orderID, string containerID, PrintReportsInfo printReportsInfo)
        {
            EncasingNoteInfo encasingNoteInfo = new EncasingNoteInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetEncasingDetailNote(orderID, containerID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetEncasingNote(string orderID, PrintReportsInfo printReportsInfo)
        {
            List<EncasingNoteInfo> encasingNoteList = new List<EncasingNoteInfo>();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetEncasingNote(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintAllocation(string receiptID, PrintReportsInfo printReportsInfo)
        {
            PrintReceiptInfo printReceiptInfo = new PrintReceiptInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintAllocation(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintBatchOutboundListReport(string waveID, string orderIDs, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintBatchOutboundListReport(waveID, orderIDs);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintBatchPickAdviceReport(string waveID, PrintReportsInfo printReportsInfo, string updatedBy)
        {
            DataSet ds = null;
            try
            {
                PubParasInfo pubParasInfo = new PubParasInfo();
                pubParasInfo.UserID = updatedBy;
                pubParasInfo.CurrentWH = printReportsInfo.CurrentWH;
                pubParasInfo.UserLanguage = "zh-CN";
                OutboundMgtBLL outboundMgtBll = new OutboundMgtBLL(pubParasInfo);
                outboundMgtBll.BatchOrderActions(waveID, "ALLOCATION", updatedBy);
                ds = new PrintReportBLL(printReportsInfo).GetPrintBatchPickAdviceReport(waveID);
                outboundMgtBll.BatchOrderActions(waveID, "REVERTALLOCATION", updatedBy);
                outboundMgtBll.BatchOrderActions(waveID, "REVERTPREALLOCATION", updatedBy);
                return ds;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintBatchPickAdviceReportByOrders(string orderIDs, PrintReportsInfo printReportsInfo, string updatedBy)
        {
            DataSet ds = null;
            try
            {
                PubParasInfo pubParasInfo = new PubParasInfo();
                pubParasInfo.UserID = updatedBy;
                pubParasInfo.CurrentWH = printReportsInfo.CurrentWH;
                pubParasInfo.UserLanguage = "zh-CN";
                OutboundMgtBLL outboundMgtBll = new OutboundMgtBLL(pubParasInfo);
                outboundMgtBll.BatchOrdersActions(orderIDs, "ALLOCATION", updatedBy);
                ds = new PrintReportBLL(printReportsInfo).GetPrintBatchPickAdviceReportByOrders(orderIDs);
                outboundMgtBll.BatchOrdersActions(orderIDs, "REVERTALLOCATION", updatedBy);
                outboundMgtBll.BatchOrdersActions(orderIDs, "REVERTPREALLOCATION", updatedBy);
                return ds;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintBatchPickListReportInfo(string orderID, PrintReportsInfo printReportsInfo)
        {
            List<PrintPickListReportInfo> printPickListReportInfo = new List<PrintPickListReportInfo>();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintBatchPickListReportInfo(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintBatchShippingOrderReport(string waveID, string orderIDs, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintBatchShippingOrderReport(waveID, orderIDs);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintCarNoticeSet(string orderID, PrintReportsInfo printReportsInfo)
        {
            PrintReceiptInfo printReceiptInfo = new PrintReceiptInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintCarNoticeSet(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintCommoditySignoff(string orderID, PrintReportsInfo printReportsInfo)
        {
            PrintCommoditySignoffInfo printCommoditySignoffInfo = new PrintCommoditySignoffInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintCommoditySignoff(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintCycleCountByReleaseID(string releaseID, PrintReportsInfo printReportsInfo)
        {
            PrintCycleCountInfo printCycleCountInfo = new PrintCycleCountInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintCycleCountByReleaseID(releaseID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintImportReceipt(string receiptID, PrintReportsInfo printReportsInfo)
        {
            PrintReceiptInfo printReceiptInfo = new PrintReceiptInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintImportReceipt(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintInventoryAdjustment(string adjustmentID, PrintReportsInfo printReportsInfo)
        {
            PrintReceiptInfo printReceiptInfo = new PrintReceiptInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintInventoryAdjustment(adjustmentID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintKittingWorkReportInfo(string orderID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintKittingWorkReportInfo(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintLoading(string loadID, PrintReportsInfo printReportsInfo)
        {
            PrintReceiptInfo printReceiptInfo = new PrintReceiptInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintLoading(loadID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintLpnLabelInfo(string lpns, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintLpnLabelInfo(lpns);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintMergePickListReportInfo(string waveID, string descr, string detailID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintMergePickListReportInfo(waveID, descr, detailID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintOrderMovementInfo(string movementID, PrintReportsInfo printReportsInfo)
        {
            PrintOrderMovementInfo printOrderMovementInfo = new PrintOrderMovementInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintOrderMovementInfo(movementID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintOutboundInfo(string OrderID, PrintReportsInfo printReportsInfo)
        {
            PrintOutboundInfo printOutboundInfo = new PrintOutboundInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintOutboundInfo(OrderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintOutboundListInfo(string OrderID, PrintReportsInfo printReportsInfo)
        {
            PrintOutboundListInfo printOutboundListInfo = new PrintOutboundListInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintOutboundListInfo(OrderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPaymentBillByMovementID(string movementID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPaymentBillByMovementID(movementID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPaymentBillByOrderID(string orderID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPaymentBillByOrderID(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPaymentBillByReceiptID(string receiptID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPaymentBillByReceiptID(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPCMaintenance(string PhysicalRequestID, string OnlyNonEmptyLoc, PrintReportsInfo printReportsInfo)
        {
            PrintPCMaintenanceListInfo printPcMaincenanceinfo = new PrintPCMaintenanceListInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPCMaintenance(PhysicalRequestID, OnlyNonEmptyLoc);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPCReview(string PhysicalRequestID, string OnlyNonEmptyLoc, PrintReportsInfo printReportsInfo)
        {
            PrintPCMaintenanceListInfo printPcMaincenanceinfo = new PrintPCMaintenanceListInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPCReview(PhysicalRequestID, OnlyNonEmptyLoc);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPickDivideReport(string waveID, string orderIDs, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPickDivideReport(waveID, orderIDs);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPickListReportInfo(string orderID, PrintReportsInfo printReportsInfo)
        {
            PrintPickListReportInfo printPickListReportInfo = new PrintPickListReportInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPickListReportInfo(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPickReportInfo(string orderID, PrintReportsInfo printReportsInfo)
        {
            PrintPickListReportInfo printPickListReportInfo = new PrintPickListReportInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPickReportInfo(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPickWorkReportInfo(string orderID, PrintReportsInfo printReportsInfo, string updatedBy)
        {
            DataSet ds = null;
            try
            {
                PubParasInfo pubParasInfo = new PubParasInfo();
                pubParasInfo.UserID = updatedBy;
                pubParasInfo.CurrentWH = printReportsInfo.CurrentWH;
                pubParasInfo.UserLanguage = "zh-CN";
                OutboundMgtBLL outboundMgtBll = new OutboundMgtBLL(pubParasInfo);
                outboundMgtBll.AutoAllocate(orderID, printReportsInfo.CurrentWH);
                ds = new PrintReportBLL(printReportsInfo).GetPrintPickWorkReportInfo(orderID);
                outboundMgtBll.AutoRevertAllocate(orderID, updatedBy);
                outboundMgtBll.AutoRevertPreAllocate(orderID, updatedBy);
                return ds;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPurchaseOrderInfo(string poID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPurchaseOrderInfo(poID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintPutawayReportInfo(string receiptID, List<string> taskDetailID, PrintReportsInfo printReportsInfo)
        {
            PrintPutawayReportInfo printPutAwayReportInfo = new PrintPutawayReportInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintPutAwayReportInfo(receiptID, taskDetailID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintQCReportInfo(string receiptID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintQCReportInfo(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintReceiptHistoryInfo(string receiptID, PrintReportsInfo printReportsInfo)
        {
            PrintReceiptHistoryInfo printReceiptHistoryInfo = new PrintReceiptHistoryInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintReceiptHistoryInfo(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintReceiptInfo(string receiptID, PrintReportsInfo printReportsInfo)
        {
            PrintReceiptInfo printReceiptInfo = new PrintReceiptInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintReceiptInfo(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintReceivableBillByMovementID(string movementID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintReceivableBillByMovementID(movementID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintReceivableBillByOrderID(string orderID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintReceivableBillByOrderID(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintReceivableBillByReceiptID(string receiptID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintReceivableBillByReceiptID(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintSalesOrderInfo(string orderID, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintSalesOrderInfo(orderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintShippingOrderID(string releaseID, List<string> pickDetailIDs, PrintReportsInfo printReportsInfo)
        {
            ShippingOrderRptInfo shippingOrderRptInfo = new ShippingOrderRptInfo();
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPringShippingOrderByShippingID(releaseID, pickDetailIDs);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }

        public DataSet GetPrintWaveShipmentReport(string waveIDs, PrintReportsInfo printReportsInfo)
        {
            try
            {
                PrintReportBLL printReportBLL = new PrintReportBLL(printReportsInfo);
                return printReportBLL.GetPrintWaveShipmentReport(waveIDs);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "PrintReportService异常");
            }
            return null;
        }
    }
}

